<template>
	<view class="f-container">
		<view class="f-item" v-for="(item,index) in classList" :key="item[keyName]" @click="onItem(item)">
			<view class="f-image">
				<image :src="item[imageName]" mode="widthFix" class="image"></image>
			</view>
			<view class="p1">
				{{item[titleName]}}
			</view>
		</view>
	</view>
</template>

<script>
export default{
	data(){
		return {
			
		}
	},
	props:{
		classList:{
			type:Array,
			default:()=>{return []}
		},
		imageName:{
			type:String,
			default:"icon"
		},
		titleName:{
			type:String,
			default:"category_name"
		},
		keyName:{
			type:String,
			default:"merchant_category_id"
		}
	},
	onShow() {
		console.log(this.classList)
	},
	methods:{
		onItem(item){
			this.$emit("onItem",item)
		}
	}
}
</script>

<style lang="scss" scoped>
.f-container{
	// margin: 20rpx 20rpx 0 20rpx;
	display: flex;
	flex-wrap: wrap;
	text-align: center;
	.f-item{
		width: 20%;
		margin-top: 12rpx;
		.image{
			width:100%;
			height: 100%;
		}
		.f-image{
			width: 80rpx;
			margin: auto;
		}
		.p1{
			font-size: 26rpx;
			margin-top: 2rpx;
		}
	}
}
</style>